/**
 * 
 */
package adnotatio.rdf;

import java.util.Iterator;

/**
 * @author kotelnikov
 */
public class ValueVisitor implements IValueVisitor {

    /**
     * 
     */
    public ValueVisitor() {
        super();
    }

    /**
     * @see adnotatio.rdf.IValueVisitor#visit(adnotatio.rdf.Container)
     */
    public void visit(Container container) {
        int size = container.getSize();
        for (int i = 0; i < size; i++) {
            PropertyValue propertyValue = container.getValue(i);
            propertyValue.accept(this);
        }
    }

    /**
     * @see adnotatio.rdf.IValueVisitor#visit(adnotatio.rdf.Literal)
     */
    public void visit(Literal literal) {
        // 
    }

    /**
     * @see adnotatio.rdf.IValueVisitor#visit(adnotatio.rdf.Model)
     */
    public void visit(Model model) {
        for (Iterator iterator = model.getResourceIterator(); iterator
            .hasNext();) {
            Resource resource = (Resource) iterator.next();
            resource.accept(this);
        }
    }

    /**
     * @see adnotatio.rdf.IValueVisitor#visit(adnotatio.rdf.Resource)
     */
    public void visit(Resource resource) {
        ID[] properties = resource.getPropertyIDs();
        for (int i = 0; i < properties.length; i++) {
            PropertyValue propertyValue = resource.getValue(properties[i]);
            propertyValue.accept(this);
        }
    }

}
